#include "OpenGL.h"
#include "PhysicsPlane.h"
#include "math.h"
PhysicsPlane::PhysicsPlane(float _width, float _height){
	width = _width;
	height = _height;
}

void PhysicsPlane::renderInternal(){
	glScalef(width, height, 1);
	glBegin(GL_QUADS);
		glNormal3f(0,0,-1);
		glVertex3f(-1,1,0);
		glVertex3f(1,1,0);
		glVertex3f(1,-1,0);
		glVertex3f(-1,-1,0);
		glNormal3f(0,0,1);	//For backfacing.
		glVertex3f(-1,-1,0);
		glVertex3f(1,-1,0);
		glVertex3f(1,1,0);
		glVertex3f(-1,1,0);
	glEnd();
}
float PhysicsPlane::inertia(){
	return getMass()*(height*height + width*width) * 1.0f/12.0f;
}
OBoundingBox PhysicsPlane::getOBoundingBox(){
	OBoundingBox ret;
	ret.position = current.position;
	ret.orientation = current.orientation;
	ret.extents = PhysicsVector(width,height,0.0f);
	return ret;
}
float PhysicsPlane::getBoundingSphere(){
	return (width*width+height*height) * 1.0f/4.0f;
}
